package com.xy.gateway.servlet;

/***********************************************************************
 * Module:  EpayGateResServlet.java
 * Author:  ligh1
 * Purpose: Defines the Class EpayGateResServlet
 ***********************************************************************/

import java.io.IOException;
import java.util.Enumeration;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

/** @pdOid a60e2258-6068-4f38-9859-5a98b4ceeb97 */
public class EpayInAmtResServlet extends HttpServlet {
	public static Logger  log= Logger.getLogger(EpayInAmtResServlet.class);

	private static Map<String, String> orderstatus_map=new LinkedHashMap<String, String>(1000);
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
		
		if(!processStats(req)){
			req.setAttribute("info","s");
			req.getRequestDispatcher("V5/CN/STY1/FEP6059.jsp").forward(
					req, res);
			return;
		}
		String txcode="EP6047";
		
		try {
			String sid=req.getParameter("rsid");
			if(sid.equals("CCB"))
				txcode="EP6049";
		} catch (Exception e1) {
			log.error("",e1);
		}
		StringBuffer vName =new StringBuffer();
		
		for(Enumeration e = req.getParameterNames(); e.hasMoreElements(); ){
			String name =(String)e.nextElement();
			String value=req.getParameter(name);
				vName.append("&"+name+"="+value);
	    }
		String url="/EPAYMainPlat?CCB_IBSVersion=V5"+"&TXCODE="+txcode+vName.toString()+"&SERVLET_NAME=EPAYMainPlat";
		RequestDispatcher requestDispatcher = this.getServletContext().getRequestDispatcher(url);
		requestDispatcher.forward(req, res);
     }

private boolean processStats(HttpServletRequest req){
	boolean canContinue=false; 
	String orderid=req.getParameter("ORDERID");
	/*String sql3 = "select states  from e_log_inamt_flow a where a.flow_no=?";
	DBACCESS db = new DBACCESS();
	Object []para3=new Object[]{orderid};		
	Vector result3=db.dbQuery( sql3,para3);
	Vector column3 = (Vector)result3.elementAt(0);
	String status = (String)column3.elementAt(0);
	if("01".equals(status))
		canContinue=false;
	else 
		canContinue=true;;*/
	return canContinue;
}
}
